home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / vgacodng / part08_c.pas < prev    next >
Pascal/Delphi Source File  |  1996-12-15  |  2KB  |  89 lines

  1. program Plasma_ASM;
  2.  
  3. uses crt;
  4.  
  5. var Wert1,Wert2,Wert3,Wert4 : byte;
  6.     TWert1,TWert2,TWert3,TWert4 : byte;
  7.     SinTab : array[0..255] of byte;
  8.     n1,n2 : word;
  9.     col : byte;
  10.  
  11. procedure SetPal(col,r,g,b:byte);
  12. begin
  13.   port[$3C8] := col;
  14.   port[$3C9] := r;
  15.   port[$3C9] := g;
  16.   port[$3C9] := b;
  17. end;
  18.  
  19. procedure CalcSinus(Ofs,Amp:byte;Len,Par:word);
  20. begin
  21.   for n1 := 0 to Len do SinTab[n1] := round(sin(n1/Par*pi*Len/180*2)*Amp)+Ofs;
  22. end;
  23.  
  24.  
  25. begin
  26.   CalcSinus(32,31,255,360);
  27.   asm mov ax,13h; int 10h end;
  28.   for n1 := 0 to 127 do begin
  29.     setpal(n1,n1 div 6,n1 div 3,n1 div 3);
  30.     setpal(255-n1,n1 div 6,n1 div 3,n1 div 3);
  31.   end;
  32.   asm
  33.     mov     ax,0A000h                  { VGA-Segment nach ES }
  34.     mov     es,ax
  35.   @mainloop:
  36.     xor     di,di                      { Bildschirmoffset auf 0 }
  37.     mov     al,Wert3                   { Werte sichern }
  38.     mov     TWert3,al
  39.     mov     al,Wert4
  40.     mov     TWert4,al
  41.     mov     n1,0                       { Zähler initialisieren }
  42.   @loop1:
  43.     mov     al,Wert1                   { Werte sichern }
  44.     mov     TWert1,al
  45.     mov     al,Wert2
  46.     mov     TWert2,al
  47.     mov     n2,0                       { Zähler initialisieren }
  48.   @loop2:
  49.     xor     bx,bx                      { Farbwert wird in BX berechnet }
  50.     mov     al,TWert4                  { Index holen }
  51.     xor     ah,ah
  52.     mov     si,ax
  53.     mov     al,[si+offset SinTab]      { Wert auslesen }
  54.     add     bx,ax                      { und auf BX addieren }
  55.     mov     al,TWert3
  56.     mov     si,ax
  57.     mov     al,[si+offset SinTab]
  58.     add     bx,ax
  59.     mov     al,TWert2
  60.     mov     si,ax
  61.     mov     al,[si+offset SinTab]
  62.     add     bx,ax
  63.     mov     al,TWert1
  64.     mov     si,ax
  65.     mov     al,[si+offset SinTab]
  66.     add     bx,ax
  67.     mov     es:[di],bl                 { Pixel setzen }
  68.     inc     di                         { Bildschirmoffset erhöhen }
  69.     add     TWert1,4                   { Indizes erhöhen }
  70.     add     TWert2,3
  71.     inc     n2
  72.     cmp     n2,320
  73.     jne     @loop2
  74.     add     TWert3,4
  75.     add     TWert4,5
  76.     inc     n1
  77.     cmp     n1,200
  78.     jne     @loop1
  79.     sub     Wert1,4
  80.     add     Wert3,4
  81.     mov     ah,0Bh
  82.     int     21h
  83.     or      al,al
  84.     jz      @mainloop
  85.   end;
  86.   readkey;
  87.   asm mov ax,3; int 10h end;
  88. end.
  89.